//
//  ZFMyIDVerifyViewController.m
//  HappilyLoan
//
//  Created by zainishenbian on 2017/3/29.
//  Copyright © 2017年 zongqingxiangqian. All rights reserved.
//

#import "ZFMyIDVerifyViewController.h"
#import "AnimatingView.h"
#import "UIButton+WebCache.h"
#import "ZFHeader.h"

@interface ZFMyIDVerifyViewController ()

@property (nonatomic,strong)ZFMyIDVerifyInfoModal *idVerifyData;
@property (nonatomic,strong) AnimatingView *anima;
@property (nonatomic,strong) AlertBoxView *alertV;
@end

@implementation ZFMyIDVerifyViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:@"myIdVerify"];
    self.navigationController.navigationBarHidden = NO;
    [_anima startTheAnimation];
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [MobClick endLogPageView:@"myIdVerify"];
}
- (void)viewDidDisappear:(BOOL)animated{
    [_anima stopTheAnimation];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    _alertV = [[AlertBoxView alloc] init];
    [self.view addSubview:_alertV];

    self.title = @"身份认证";
    [self.DetailAddressTextView setEditable:NO];
    self.SureBut.hidden = YES;
    [ZFMyInfoHttpRequest requestfindUserIdentitysucessBlock:^(NSDictionary *dict) {
        
        if ([dict[@"is_alert"] integerValue] == 1) {
            
            [self showAlertView:dict[@"msg"]];
        }
        if ([dict[@"code"] integerValue] == 1) {
            
            if (dict[@"data"] != [NSNull null]) {
                
                _idVerifyData = [ZFMyIDVerifyInfoModal getMyIDVerifyInfoDictionary:dict[@"data"]];
                [self loadUserInfoData];
            }
        }
    } failureBlock:^(NSInteger failSign) {
        [_alertV appearAndDisappearAlertWithString:@"网络连接失败"];
    }];
    
    self.anima = [[AnimatingView alloc] initWithFrame:self.view.bounds];
}
- (void)loadUserInfoData{
    
    [_anima stopTheAnimation];
    
    [_PersonalFaceButton setImage:nil forState:UIControlStateNormal];
    [_IdentificationButton setImage:nil forState:UIControlStateNormal];
    [_IdentificationotherButton setImage:nil forState:UIControlStateNormal];
    
    _NameField.text = [NSString stringWithFormat:@"%@",_idVerifyData.true_name];
    _IdentificationCard.text = [NSString stringWithFormat:@"%@",_idVerifyData.idcard_no];
    [_ad_pathButton setTitle:_idVerifyData.ad_path forState:UIControlStateNormal];
    _DetailAddressTextView.text = [NSString stringWithFormat:@"%@",_idVerifyData.detail_address];
    [_PersonalFaceButton sd_setBackgroundImageWithURL:[NSURL URLWithString:_idVerifyData.face_photo] forState:UIControlStateNormal placeholderImage:nil options:SDWebImageAllowInvalidSSLCertificates];
    [_IdentificationButton sd_setBackgroundImageWithURL:[NSURL URLWithString:_idVerifyData.idcard_front] forState:UIControlStateNormal placeholderImage:nil options:SDWebImageAllowInvalidSSLCertificates];
    [_IdentificationotherButton sd_setBackgroundImageWithURL:[NSURL URLWithString:_idVerifyData.idcard_back] forState:UIControlStateNormal placeholderImage:nil options:SDWebImageAllowInvalidSSLCertificates];
}
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    return NO;
}
//人脸识别
- (IBAction)PersonalFaceButton:(UIButton *)sender {
}
//左身份识别
- (IBAction)IdentificationButton:(UIButton *)sender {
}
//右身份识别
- (IBAction)IdentificationotherButton:(UIButton *)sender {
}
//确定
- (IBAction)SureButton:(UIButton *)sender {
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
